/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package app.entities.model.MockDAOImpl;

import app.entities.MOCK.MockPersistencia;
import app.entities.model.DAO.MatriculaProfessorDAO;
import app.entities.model.DTO.MatriculaProfessorDTO;
import java.util.ArrayList;

/**
 *
 * @author Murilo
 */
public class MockMatriculaProfessorDAOImpl implements MatriculaProfessorDAO {

    @Override
    public void salvar(MatriculaProfessorDTO dto) {
        MockPersistencia.getInstanciaListaMatriculaProfessores().add(dto);
    }

    @Override
    public void deletar(MatriculaProfessorDTO dto) {
        MockPersistencia.getInstanciaListaMatriculaProfessores().remove(dto);
    }

    @Override
    public void atualizar(MatriculaProfessorDTO dto) {
        for(MatriculaProfessorDTO mp : MockPersistencia.getInstanciaListaMatriculaProfessores()){
            if(mp.getId() == dto.getId()){
                mp.setProfessor(dto.getProfessor());
                mp.setCodigoMatricula(dto.getCodigoMatricula());
                mp.setDataMatricula(dto.getDataMatricula());
                mp.setEstaAtiva(dto.isEstaAtiva());
            }
        }
    }

    @Override
    public ArrayList listar() {
        return MockPersistencia.getInstanciaListaMatriculaProfessores();
    }
    
    @Override
    public MatriculaProfessorDTO buscarMatriculaProfessor(String Codigomatricula){
        for(MatriculaProfessorDTO matricula : MockPersistencia.getInstanciaListaMatriculaProfessores()){
            if(matricula.getCodigoMatricula().equals(Codigomatricula)){
                return matricula;
            }
        }
        return null;
    }
}
